CNN Image Pattern Recognition

Background

This model relies on technical features which would be utilized by day traders - candlestick charts with moving averages and Bollinger bands. There were 10 stocks, and 2 ETFs that were selected to trade due to their high intraday volume, however the choices were limited due to Alpha Vantage . These stocks and ETFs were NVDA, AMD, JPM, JNJ, MRNA, F, TSLA, MSFT, BAC, BABA, SPY, and QQQ.

The historical intraday stock values of open, high, low, close were all used to train the model by creating candlesticks every 5 or 15 minute intervals. These larger intervals were chosen, compared to 1 minute or 2 minute intervals, because at the small intervals there were a lot of timestamps which had no volume, meaning no trades and no volatility. The CNN is used as an image pattern recognition model to recognize when the stock will go up or go down given the candlestick charts.

https://joeykess.github.io/SIADS697/assets/cnn.jpg Above is a CNN model schema example seen here. The first part consists of Convolutional and max-pooling layers, while the second part consists of the fully connected layer, which performs non-linear transformations of the extracted features and, in this case, acts as the classifier. Two types of outputs here can be either a softmax or a sigmoid layer, which will tell whether the image is of a cat or not, or probabilty of the image being a cat.

Why a CNN model?

CNNs are fully connected feed forward neural networks, and are very effective in reducing number of parameters without losing the quality of the model. Since images have a lot of features, with each pixel considered its own feature, they have very high dimensionality. Thus, since CNNs are good at dimension reduction without loss of quality in the model, CNNs are good with images.

Two classes are used here, buy and don't buy. In this situation, the image below is a 'buy' signal. After creating these images comes training the CNN, which is seen below in the train_cnn_model function. This is a sample model with modified parameters in order to run quickly, as this was ran using short_cnn.py file instead.